//
//  GTLeftViewController.m
//  GameTesting
//
//  Created by jojojiong on 15/4/14.
//  Copyright (c) 2015年 jojojiong. All rights reserved.
//

#import "GTLeftViewController.h"
#import "GTLeftViewCell.h"
#import "AppDelegate.h"
#import "JVFloatingDrawerViewController.h"

enum {
    kGTDanjiGameIndex    = 0,
    kGTMobileGameIndex = 1,
    kGTNetGameIndex = 2
};

static const CGFloat kGTTableViewTopInset = 80.0;
static NSString * const kGTLeftCellReuseIdentifier = @"menu";

@interface GTLeftViewController ()

@end

@implementation GTLeftViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.tableView.backgroundColor = [UIColor clearColor];
    self.tableView.contentInset = UIEdgeInsetsMake(kGTTableViewTopInset, 0.0, 0.0, 0.0);
    self.clearsSelectionOnViewWillAppear = NO;
    [self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];

}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForItem:kGTDanjiGameIndex inSection:0] animated:NO scrollPosition:UITableViewScrollPositionNone];
}



#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    // Return the number of rows in the section.
    return 3;
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    GTLeftViewCell *cell = [GTLeftViewCell cellWithTableView:tableView];
    switch (indexPath.row) {
        case kGTDanjiGameIndex:
            cell.titleText = @"单机游戏";
            cell.iconImage = [UIImage imageNamed:@"665-gear"];
            break;
        case kGTMobileGameIndex:
            cell.titleText = @"手机游戏";
            cell.iconImage = [UIImage imageNamed:@"488-github"];
            break;
        case kGTNetGameIndex:
            cell.titleText = @"网络游戏";
            cell.iconImage = [UIImage imageNamed:@"488-github"];
            break;
    }
    return cell;
}



- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    UIViewController *destinationViewController = nil;
    
    switch (indexPath.row) {
        case kGTDanjiGameIndex:
            destinationViewController = [[AppDelegate globalDelegate] danjiViewController];
            break;
        case kGTMobileGameIndex:
            destinationViewController = [[AppDelegate globalDelegate] mobileViewController];
            break;
        case kGTNetGameIndex:
            destinationViewController = [[AppDelegate globalDelegate] netGameViewController];
            break;
    }
    
    [[[AppDelegate globalDelegate] drawerViewController] setCenterViewController:destinationViewController];
    [[AppDelegate globalDelegate] toggleLeftDrawer:self animated:YES];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 60;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
